<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if ( ! function_exists('buses_dropdown'))
{
	function buses_dropdown($buses, $selected = null, $count = null, $prefix = null, $activated = false)
	{
		$name = 'bus_type';
		if ($prefix != null)
		{
			$name = $prefix . '[bus_type]';
		}
		
		$d = "<select name=\"$name\" id=\"$name\">\n";
		
		if (!$activated)
		{
			$d .= "\t<option value=\"0\">Please select...</option>\n";
		}
		
		for ($i = 0; $i < count($buses); $i++)
		{
			if (($selected == $buses[$i]['id']) || (isset($_POST['bus']) && $_POST['bus'] == $buses[$i]['id']))
			{
				$s = ' selected="selected"';
			} else
			{
				$s = '';
			}
			
			$d .= "\t<option value=\"" . $buses[$i]['id'] . "\"" . $s . ">" . $buses[$i]['bus_name'] . " - " . $buses[$i]['capacity'] . " seats</option>\n";
		}
			
		
		$d .= "</select>";
		return $d;
	}
}

?>